/**************************************************************
  > File Name: getsockopt.c
  > Author: LuoLiang
  > Mail: 1204553475@qq.com 
  > Created Time: 2022年03月09日 星期三 03时15分29秒
 **************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>

int main(int argc, char **argv)
{
    int sockfd;

    sockfd =  socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd < 0)
    {
        perror("socket()");
        exit(1);
    }
    
    int val = 0;
    socklen_t len = sizeof(val);
    getsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, (void *)&val, &len);
    printf("%d\n", val);
    getsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (void *)&val, &len);
    printf("%d\n", val);
    exit(0);
}
